package com.thf.controller.news;

import com.alibaba.fastjson.JSON;
import com.thf.model.ResultData;
import com.thf.service.impl.NewsServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Map;

@Controller
public class NewFindAllController{

    @Resource
    private NewsServiceImpl newsService ;
    @RequestMapping("/back/news/findAll")
    @ResponseBody
    public String newFindAll(@RequestParam("val") String data) throws ServletException, IOException {

        ResultData result = null ;
        System.out.println(data);
        Map map = JSON.parseObject(data ,Map.class);
        result = newsService.newsFindAll(map);

        //       反馈给前端--返回值
        String resJson = JSON.toJSONString(result);
        //System.out.println(resJson);
//        resp.getWriter().println(resJson);
        return resJson ;
    }
}
